<script type="text/javascript" src="<?=site_url()?>js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="<?=site_url()?>js/jquery-ui-1.8.custom.min.js"></script>
<script type="text/javascript" src="<?=site_url()?>js/jquery.ui.datepicker-th.js"></script>
<script type='text/javascript' src='<?=site_url()?>js/jquery.bgiframe.min.js'></script>
<script type='text/javascript' src='<?=site_url()?>js/jquery.ajaxQueue.js'></script>
<script type='text/javascript' src='<?=site_url()?>js/jquery.autocomplete.js'></script>
<script type='text/javascript' src='<?=site_url()?>js/localdata.js'></script>
<link type="text/css" href="<?=site_url()?>js/ui/themes/start/jquery.ui.all.css" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="<?=site_url()?>css/jquery.autocomplete.css" />
<style>
.ui-datepicker {
	width: 15em;
}
.ui-widget {
	font-size: 10pt;
}
.ui-datepicker select.ui-datepicker-month, .ui-datepicker select.ui-datepicker-year {
	width: 60px;
}
</style>
<script language="javascript">
	$().ready(function() {
		$("#txtDatePicker").datepicker({
			showOn: 'button',
			buttonImage: '<?=base_url()?>images/calbtn.gif',
			buttonImageOnly: true,
			changeMonth: true,
			changeYear: true,
			yearRange: 'c-5:c+5'
		});		

		
	$("#txtProvince").autocomplete(provinces, {
		minChars: 0,
		max: 20,
		autoFill: false,
		mustMatch: false,
		matchContains: false,
		scrollHeight: 100,
		formatItem: function(data, i, total) {
			return data[0];
		}
	});	

	$("#txtArea").autocomplete(areas, {
		minChars: 0,
		max: 20,
		autoFill: false,
		mustMatch: false,
		matchContains: false,
		scrollHeight: 100,
		formatItem: function(data, i, total) {
			return data[0];
		}
	});	

	$("#txtDistinct").autocomplete(distincts, {
		minChars: 0,
		max: 20,
		autoFill: false,
		mustMatch: false,
		matchContains: false,
		scrollHeight: 100,
		formatItem: function(data, i, total) {
			return data[0];
		}
	});	

	$("#txtRoad").autocomplete(road, {
		minChars: 0,
		max: 20,
		autoFill: false,
		mustMatch: false,
		matchContains: false,
		scrollHeight: 100,
		formatItem: function(data, i, total) {
			return data[0];
		}
	});	
	});	

	function checkImageExt(obj) {
		var t = obj.value;
		var txt = obj.value.substring(obj.value.lastIndexOf(".")+1).toLowerCase();
		if(!(txt == "jpg" || txt == "jpeg" || txt == "gif" || txt == "png" || txt == "pdf")) {
			alert("ไฟล์รูปภาพที่แนบมาไม่ถูกต้อง " + t + "\nกรุณาเลือกไฟล์ใหม่");	
		}
	}
	function trim(stringToTrim) {
		return stringToTrim.replace(/^\s+|\s+$/g,"");
	}
	function handleSubject(obj) {
		var txt = 'txtSubjectOther' + obj.id.substring(obj.id.length - 2);
		if(obj.value == "อื่นๆ (โปรดระบุ)") {
			document.getElementById(txt).style.visibility="visible";
			document.getElementById(txt).focus();
		} else {
			document.getElementById(txt).style.visibility="hidden";
			document.getElementById(txt).value = '';
		}
	}
	
	function handleObj(obj) {
		if(obj.value == "อื่นๆ (โปรดระบุ)" || obj.value == "สอบแข่งขัน" ) {
			document.getElementById('txtObjOther').style.visibility="visible";
			document.getElementById('txtObjOther').focus();
		} else {
			document.getElementById('txtObjOther').style.visibility="hidden";
			document.getElementById('txtObjOther').value = '';
		}
	}
	function handleKnown(obj) {
		if(obj.value == "มีผู้แนะนำ" || obj.value == "อื่นๆ") {
			document.getElementById('txtKnownOther').style.visibility="visible";
			document.getElementById('txtKnownOther').focus();
		} else {
			document.getElementById('txtKnownOther').style.visibility="hidden";
			document.getElementById('txtKnownOther').value = '';
		}
	}
	function validateForm() {
		if( trim(document.getElementById('txtMon').value).length == 0 && 
			trim(document.getElementById('txtTue').value).length == 0 &&
			trim(document.getElementById('txtWed').value).length == 0 &&
			trim(document.getElementById('txtThu').value).length == 0 &&
			trim(document.getElementById('txtFri').value).length == 0 &&
			trim(document.getElementById('txtSat').value).length == 0 &&
			trim(document.getElementById('txtSun').value).length == 0 ) {
			document.getElementById('txtMon').focus();
			alert("กรุณาระบุช่วงเวลาที่ต้องการเรียน");
			return;		
		}
		if(trim(document.getElementById('txtDatePicker').value).length == 0) {
			document.getElementById('txtDatePicker').focus();
			alert("กรุณาเลือกวันที่ต้องการเริ่มเรียน");
			return;		
		} 
		if(trim(document.getElementById('selKnown').value).length == 0) {
			document.getElementById('selKnown').focus();
			alert("กรุณาเลือก รู้จักติวเตอร์แลนด์จาก?");
			return;		
		} 
		document.forms["myForm"].submit();
	}
</script>
	
<table width="915" border="0" cellspacing="0" cellpadding="0" align="center">
      <tr>
        <td width="86"><img src="<?=site_url()?>images/registerstudy_increase_14.jpg" width="86" height="850" alt="" /></td>
        <td width="739" valign="top" bgcolor="#FFFFFF">
        <form name="myForm" id="myForm" enctype="multipart/form-data" method="post" action="<?=site_url()?>register_study/save3" onsubmit="return validateForm();">
        <input  type="hidden"  id="txtID" name="txtID" value="<?=$id?>" />
        <table width="739" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="37"><br/><table width="739" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td height="164"><table width="739" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td height="552"><table id="Table_3" width="739" height="552" border="0" cellpadding="0" cellspacing="0">
                      <tr>
                        <td><img src="<?=site_url()?>images/registerstudy_increase_22_01.jpg" width="739" height="100" alt="" /></td>
                      </tr>
                      <tr >
						<td background="<?=site_url()?>images/registerstudy_increase_22_02.jpg">
						                        
                        <table align="center" border="0" cellspacing="1" cellpadding="1" class="styleLabel">
                      <tr >
                        <td>&nbsp;</td>
                        <td><div align="center"><strong></strong></div></td>
                        <td><div align="center"><strong>ช่วงเวลาที่ต้องการเรียน</strong></div></td>
                      </tr>
                      <tr>
                        <td ><div align="right"><span class="red">ตัวอย่าง</span></div></td>
                        <td ><div align="center"><span class="style2">จันทร์</span></div></td>
                        <td >
                          <div align="center">
                            <input name="textfield9" type="text" class="style2" id="textfield9" value="15.00-16.00, หรือหลัง 18.00" size="62" disabled="disabled" />                        
                          </div></td>
                      </tr>
                      <tr>
                        <td ><div align="right"><span class="red">ตัวอย่าง</span></div></td>
                        <td ><div align="center"><span class="style2">อาทิตย์</span></div></td>
                        <td ><div align="center">
                          <input name="textfield7" type="text" class="style2" id="textfield14" value="ทั้งวัน" size="62" disabled="disabled"/>
                        </div></td>
                      </tr>
                      <tr>
                        <td>&nbsp;</td>
                        <td><div align="center">จันทร์</div></td>
                        <td>
                          <div align="center">
                            <input name="txtMon" type="text" id="txtMon" size="50" maxlength="100" value="<?php if(isset($study_time_mon)) echo $study_time_mon;?>" />                        
                          </div></td>
                      </tr>
                      <tr >
                        <td>&nbsp;</td>
                        <td><div align="center">อังคาร</div></td>
                        <td><div align="center">
                          <input name="txtTue" type="text" id="txtTue" size="50" maxlength="100" value="<?php if(isset($study_time_tue)) echo $study_time_tue;?>" />
                        </div></td>
                      </tr>
                      <tr>
                        <td>&nbsp;</td>
                        <td><div align="center">พุธ</div></td>
                        <td><div align="center">
                          <input name="txtWed" type="text" id="txtWed" size="50" maxlength="100" value="<?php if(isset($study_time_wed)) echo $study_time_wed;?>" />
                        </div></td>
                      </tr>
                      <tr >
                        <td>&nbsp;</td>
                        <td><div align="center">พฤหัสบดี</div></td>
                        <td><div align="center">
                          <input name="txtThu" type="text" id="txtThu" size="50" maxlength="100" value="<?php if(isset($study_time_thr)) echo $study_time_thr;?>" />
                        </div></td>
                      </tr>
                      <tr>
                        <td>&nbsp;</td>
                        <td><div align="center">ศุกร์</div></td>
                        <td><div align="center">
                          <input name="txtFri" type="text" id="txtFri" size="50" maxlength="100" value="<?php if(isset($study_time_fir)) echo $study_time_fir;?>" />
                        </div></td>
                      </tr>
                      <tr >
                        <td>&nbsp;</td>
                        <td><div align="center">เสาร์</div></td>
                        <td><div align="center">
                          <input name="txtSat" type="text" id="txtSat" size="50" maxlength="100" value="<?php if(isset($study_time_sat)) echo $study_time_sat;?>" />
                        </div></td>
                      </tr>
                      <tr>
                        <td>&nbsp;</td>
                        <td><div align="center">อาทิตย์</div></td>
                        <td><div align="center">
                          <input name="txtSun" type="text" id="txtSun" size="50" maxlength="100" value="<?php if(isset($study_time_sun)) echo $study_time_sun;?>" />
                        </div></td>
                      </tr>
                    </table>
                        <table class="styleLabel" align="center" cellpadding="1" cellspacing="1">
                    <tr style="vertical-align:top">
                    <td align="right"><label>วันที่ต้องการเริ่มเรียน</label></td>
                    <td align="left"><input name="txtDatePicker" type="text" class="textReadonly" id="txtDatePicker" readonly="readonly" value="<?php if(isset($study_start_date)) echo $study_start_date;?>" />
                    <span class="red">*</span></td>
                  </tr>
                  <tr style="vertical-align:top">
                    <td align="right"><label>ความต้องการอื่นๆ</label><br /></td>
                    <td align="left">
                    	เช่น ระบุลักษณะของติวเตอร์ที่ต้องการ (เช่น อยากเรียนกับติวเตอร์วัยรุ่น,<br> สอนสนุก, เน้นเนื้อหา), มีเพื่อนต้องการเรียนด้วย 3 คน <br/>
                    	<textarea name="txtNote" id="txtNote" cols="45" rows="8" ><?php if(isset($note)) echo $note;?></textarea></td>
                  </tr>
                  <tr>
                    <td align="right" ><label>รู้จัก Tutorland จาก </label></td>
                    <td align="left"><select name="selKnown" id="selKnown" onchange="handleKnown(this);">
                      <option value="" <?php if(isset($known_from) == false) echo 'selected="selected"'?>>---รู้จัก Tutor Land จาก---</option>
                      <option value="Google" <?php if(isset($known_from) && $known_from == 'Google') echo 'selected="selected"'?>>Google</option>
                      <option value="มีผู้แนะนำ" <?php if(isset($known_from) && $known_from != 'Google') echo 'selected="selected"'?>>มีผู้แนะนำ</option>
                      <option value="อื่นๆ" <?php if(isset($known_from) && $known_from != 'Google') echo 'selected="selected"'?>>อื่นๆ</option>
                      </select>
                        <label>
                        <input name="txtKnownOther" type="text" id="txtKnownOther" maxlength="45" <?php if(!(isset($known_from) && $known_from != 'Google')) echo 'style="visibility:hidden;"'?> value="<?php if(isset($known_from)) echo $known_from;?>" />
                        </label></td>
                  </tr>
                    </table>
                        
                        </td>
                      </tr>
                      <tr>
                        <td><img src="<?=site_url()?>images/registerstudy_increase_22_03.jpg" width="739" height="50" alt="" /></td>
                      </tr>
                    </table></td>
                  </tr>
                  <tr>
                    <td width="580" height="55" align="right">
                    	<a href="javascript:validateForm();" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image51','','<?=site_url()?>images/registerstudy_increaseroll_25.jpg',1)"><img src="<?=site_url()?>images/registerstudy_increase_25.jpg" name="Image51" width="89" height="55" border="0" id="Image51" /></a>
                    </td>
                    </tr>
                  </table></td>
              </tr>
            </table></td>
            </tr>
        </table></form></td>
        <td width="90"><img src="<?=site_url()?>images/registerstudy_increase_18.jpg" width="90" height="850" alt="" /></td>
      </tr>
    </table>